Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Eliminate distortions in phasediff images caused by unmasked fieldmap estimates #3094

Closed
wants to merge 2 commits into from

Conversation

effigies
Copy link
Member

@effigies effigies commented Sep 26, 2023

Changes proposed in this pull request

To recap how fieldmaps are handled in fMRIPrep, we have multiple ways of computing a fieldmap:

  1. Pepolar: (dir1, dir2) -> b-spline estimate -> field -> voxel shift map
  2. Phasediff/fieldmap: field estimate -> field -> voxel shift map
  3. SyN-SDC: (epi, anat) -> voxel shift map

The voxel shift map is a brittle representation, and the direct field estimate potentially contains high frequency spatial noise. We therefore have shifted to the following method:

  • Fit
    1. Pepolar: (dir1, dir2) -> b-spline estimate
    2. Phasediff/fieldmap: field estimate -> field -> b-spline estimate
    3. SyN-SDC: (epi, anat) -> voxel shift map -> field -> b-spline estimate
  • Apply
    • b-spline estimate -> field -> voxel shift map

The problems we're seeing in #3013, #3093, etc, occur in the application stage for case 2. Here, the field is extremely noisy outside the skull, and so we can only get a good fit of the field in-brain by fitting the splines to the masked image. Because there are peaks going to the edge of the mask, the splines actually fit peaks outside the brain, and reconstructing the field without applying the mask to the result produces nonsense that pulls EPI signal outside the brain.

The good news is that the values inside the brain are basically fine, and the main problem is that it is difficult to assess the quality with such large distortions. However, if these distortions affect the coregistration, that could also produce problems.

In any event, this PR starts to fix it. I need to test to make sure that this is not introducing regressions for pepolar or SyN-SDC.

Fixes #3013.

Documentation that should be reviewed

@codecov
Copy link

codecov bot commented Sep 26, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (8d11614) 47.09% compared to head (d642566) 47.09%.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #3094   +/-   ##
=======================================
  Coverage   47.09%   47.09%           
=======================================
  Files          49       49           
  Lines        4015     4015           
=======================================
  Hits         1891     1891           
  Misses       2124     2124           
Files Coverage Δ
fmriprep/workflows/bold/fit.py 25.00% <ø> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@themeo
Copy link

themeo commented Sep 26, 2023

Please note that some of the examples in #3013 used pepolar so if this fix addresses only b-splines estimated from phasediff/fieldmap, it is not going to fully solve #3013. In any case, thanks for working on this issue(s)!

@effigies
Copy link
Member Author

Changes to the workflow are no longer needed. The fix was entirely internal to SDCflows.

@effigies effigies closed this Sep 29, 2023
@effigies effigies deleted the fix/sdc-distortions branch September 29, 2023 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants